package com.pk.platform.business.privilege.dao.impl;

import java.util.List;

import com.pk.platform.business.core.dao.impl.GenericDaoImpl;
import com.pk.platform.business.privilege.dao.IMenuDao;
import com.pk.platform.domain.privilege.Menu;

public class MenuDaoImpl extends GenericDaoImpl implements IMenuDao {

	public List<Menu> queryTopMenu(Long id) {
		String hql = "from Menu m where m.parentId = ? order by m.sort";
		List<Menu> list = this.getHibernateTemplate().find(hql, new Object[]{id});
		return list;
	}
	
	public int queryChildrenCountByMenuId(Long menuId)
	{
		String sql = "select count(id) from p_menu where parentId = ?";
		Integer count = this.getSjt().queryForInt(sql, menuId);
		return count.intValue();
	}
	
	public List<Menu> queryMenuListExcludeItself(Long menuId)
	{
		String hql = "from Menu m where m.id != ?";
		return this.getHibernateTemplate().find(hql, new Object[]{menuId});
	}
	
	public List<Menu> querySysMenu()
	{
		String hql = "from Menu m";
		List<Menu> list = this.getHibernateTemplate().find(hql);
		return list;
	}

}
